package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.common.MessageConst;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetMealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* @Author : wangjie
* @CreateDate : 2020/4/5 10:46
* @Version : 1.0
* @Description : 移动端 前端控制器
*/
@RestController
@RequestMapping("mobile/setmeal")
public class SealmealController {
    @Reference
    private SetMealService setMealService;

    /**
     * 移动端 套餐列表展示
     * @return
     */
    @RequestMapping("getSetmeal")
    public Result getSetmeal(){
        try {
            List<Setmeal> setmealList= setMealService.getSetmeal();
            System.out.println("setmealList = " + setmealList);
            return new Result(true, MessageConst.QUERY_SETMEALLIST_SUCCESS,setmealList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConst.QUERY_SETMEALLIST_FAIL);
        }
    }
    @RequestMapping("findById")
    public Result findById(Integer id){
        try {
            Setmeal setmeal= setMealService.findById(id);
            return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConst.QUERY_SETMEAL_FAIL);
        }
    }
}
